import javax.swing.*;
import java.awt.event.ActionEvent;

public class NPC implements Player
{
	//private static String name = "电脑";
	private static int score;
	//static {NPC npc1 = new NPC();}
	private static String npcName = "派蒙";
	@Override
	public int out()
	{
		
		int pc = (int) (Math.random() * 3);
		System.out.println("pc认为:"+pc);
		switch (pc)
		{
			case 0:MainWindow.labelNPC.setText(npcName+"出石头");break;
			case 1:MainWindow.labelNPC.setText(npcName+"出剪刀");break;
			case 2:MainWindow.labelNPC.setText(npcName+"出布");break;
		}
		
		return pc;
	}
	static JFrame frameAddNPC;
	
	static JPanel panelAddNPC;
	static JLabel labelAddNPC;
	static JButton ok;
	static JTextField getName;
	
	static
	{
		frameAddNPC =new JFrame("设置电脑玩家");
		frameAddNPC.setLocation(1000, 500);  // 设置窗体坐上顶点坐标
		frameAddNPC.setSize(300, 150);   // 窗体大小
		//f_AddNPC.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frameAddNPC.setLocationRelativeTo(null);
	}
	
	public static void addNPC()
	{
		
		ok = new JButton("确定");
		getName = new JTextField(NPC.getName(),10);
		
		//f_AddNPC.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
		
		panelAddNPC =new JPanel();
		
		labelAddNPC =new JLabel("输入电脑玩家名称");
		
		//f_AddNPC.setBounds(0,0,300,200);
		//jf_AddNPC.setFont(new Font(null,15));
		
		frameAddNPC.setContentPane(panelAddNPC);
		
		//p_AddNPC.add(jl_AddNPC);
		
		panelAddNPC.add(getName);
		panelAddNPC.add(ok);
		
	//	f_AddNPC.setLocation(500, 500);
		//jf_AddNPC.add(jp_AddNPC, BorderLayout.NORTH);
		getName.setHorizontalAlignment(SwingConstants.CENTER);
		frameAddNPC.setVisible(true);
		
		//添加按钮事件
		ok.addActionListener(new AbstractAction()
		{
			@Override
			public void actionPerformed(ActionEvent e)
			{
				 // getName.getText();
				System.out.println("设置NPC名称：" + getName.getText());
				MainWindow.textA.append("设置NPC："+ getName.getText()+"\n");
				npcName = getName.getText();
				frameAddNPC.dispose();
			}
		});
	
	}
	//get/set
	public static String getName()
	{
		return npcName;
	}

	public void setName(String name)
	{
		NPC.npcName = name;
	}

	public static int getScore()
	{
		return score;
	}

	public static void setScore(int score)
	{
		NPC.score = score;
	}







}
